﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class DownloadCourseware : DLL.MyWebPage
{
	protected void Page_Load(object sender, EventArgs e)
	{
		int nCoursewareID = 0;

		try
		{
			nCoursewareID = Convert.ToInt32(Request["CoursewareID"]);
			Download(nCoursewareID);
		}
		catch
		{
			nCoursewareID = 0;
			TonyNet4V1.ShowMessageAlert.ShowError(Page, "CoursewareID！");
		}
	}

	private void Download(int nCoursewareID)
	{
		DLL.Courseware.Component clsCoursewareComp = new DLL.Courseware.Component(Page);
		DLL.Courseware.Entity clsCourseware = new DLL.Courseware.Entity();

		clsCourseware = clsCoursewareComp.GetOne(nCoursewareID);

		if (clsCourseware != null)
		{
			Response.ContentType = clsCourseware.Type;
			Response.AddHeader("Content-Disposition", "attachment;filename=" + TonyNet4V1.CommonFunction.UTF_FileName(clsCourseware.Name) + "");

			//Response.Redirect(clsCourseware.Path);
			string filename = Server.MapPath(clsCourseware.Path);
			Response.TransmitFile(filename);
		}
	}
}